using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib.daily;
using buildingLib.engineering;
namespace _dmis
{
    public partial class EditComplaint : UIToolBase
    {
        Complaint m_complaint;
       
        public EditComplaint(Complaint complaint,string title,bool isFeedback)
        {
            InitializeComponent();
            m_complaint = complaint;
            this.Text = title;
            if(isFeedback)
            {
                raiserTextBox.ReadOnly = telTextBox.ReadOnly = recorderTextBox.ReadOnly
                 = rcontentTextBox.ReadOnly = true;
                rdateDateTimePicker.Enabled = false;
                

            }
        }

        private void NewComplaint_Load(object sender, EventArgs e)
        {            
            complaintsBindingSource.DataSource = m_complaint;
            cb_finished_CheckedChanged(sender, e);
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (m_complaint.IsValid)
            {
                this.DialogResult = DialogResult.OK;                
            }
            
        }

        private void cb_finished_CheckedChanged(object sender, EventArgs e)
        {
            if (cb_finished.Checked)
            {
                resultTextBox.Enabled = true;
                reasonTextBox.Enabled = true;
                commentsTextBox.Enabled = true;
                ddateDateTimePicker.Enabled = true;

                m_complaint.Ddate = DateTime.Now;
            }
            else
            {
                resultTextBox.Enabled = false;
                reasonTextBox.Enabled = false;
                commentsTextBox.Enabled = false;
                ddateDateTimePicker.Enabled = false;
                m_complaint.Ddate = DateTime.MaxValue;
               
            }
        }               
    }
}

